package mystring

import (
	"fmt"
	"strings"
)

func Opration() {
	fmt.Println("func opration():")

	//字符串拆分成切片
	s := "aaa bbb ccc"
	sSlice := strings.Split(s, " ")
	fmt.Println("sSlice:", sSlice)

	//字符串拆分成切片，支持多个空格
	s1 := "aaa bbb   ccc"
	s1Slice := strings.Fields(s1)
	fmt.Println("s1Slice:", s1Slice)

	//切片组成字符串
	s2 := strings.Join(s1Slice, ",")
	fmt.Println("s2:", s2)

	//字符串是否包含指定子串
	ssss := "123abcxyz"
	fmt.Println("ssss is contains 123:", strings.Contains(ssss, "123"))

	//字符串索引
	sssss := "abcdefg"
	fmt.Println("sssss's index is:", strings.Index(sssss, "c"))
	//转大写
	sssssBig := strings.ToUpper(sssss)
	fmt.Println("sssss to upper:", sssssBig)
	fmt.Println("sssssBig to lower:", strings.ToLower(sssssBig))
	fmt.Println("====================================================")
}
